﻿/***
 * 
 * 平台相关的一些功能
 * 
 */

using System.Collections.Generic;
using UnityEngine;

public static class ApplicationHelper
{
    /// <summary>
    /// 判断当前网络
    /// </summary>
    /// <returns></returns>
    public static bool IsWifi()
    {
        return IsNetWork(NetworkReachability.ReachableViaLocalAreaNetwork);
    }
    /// <summary>
    /// 
    /// </summary>
    /// <param name="net"></param>
    /// <returns></returns>
    public static bool IsNetWork(NetworkReachability net)
    {
        return Application.internetReachability == net;
    }

    /// <summary>
    /// 获取网络状态
    /// 说明：这个不确定是否能链接上网络，如果判断网络状态，需要ping百度
    /// </summary>
    /// <returns></returns>
    public static string GetNetworkState()
    {
        string internetState = string.Empty;
        if (Application.internetReachability == NetworkReachability.NotReachable)
            internetState = "当前网络：不可用";
        else if (Application.internetReachability == NetworkReachability.ReachableViaCarrierDataNetwork)
            internetState = "当前网络：3G/4G";
        else if (Application.internetReachability == NetworkReachability.ReachableViaLocalAreaNetwork)
            internetState = "当前网络 : WIFI";
        return internetState;
    }
    /// <summary>
    /// 复制内容到剪切板
    /// </summary>
    /// <param name="str"></param>
    public static void CopyToClipBoard(string str)
    {
        if (!string.IsNullOrEmpty(str))
            GUIUtility.systemCopyBuffer = str;
    }

    public static Dictionary<string, string> GetSystemInfo()
    {
        // TODO Test log, please do not copy it


        Dictionary<string, string> extras = new Dictionary<string, string>();
        extras.Add("ScreenSolution", string.Format("{0}x{1}", Screen.width, Screen.height));
        extras.Add("deviceModel", SystemInfo.deviceModel);
        extras.Add("deviceName", SystemInfo.deviceName);
        extras.Add("deviceType", SystemInfo.deviceType.ToString());

        //敏感权限不获取
        //extras.Add("deviceUId", SystemInfo.deviceUniqueIdentifier);
        //extras.Add("gDId", string.Format("{0}", SystemInfo.graphicsDeviceID));
        //extras.Add("gDName", SystemInfo.graphicsDeviceName);
        //extras.Add("gDVdr", SystemInfo.graphicsDeviceVendor);
        //extras.Add("gDVer", SystemInfo.graphicsDeviceVersion);
        //extras.Add("gDVdrID", string.Format("{0}", SystemInfo.graphicsDeviceVendorID));

        extras.Add("graphicsMemorySize", string.Format("{0}", SystemInfo.graphicsMemorySize));
        extras.Add("systemMemorySize", string.Format("{0}", SystemInfo.systemMemorySize));
        extras.Add("UnityVersion", Application.unityVersion);

        return extras;

    }
}
